package com.newer.web.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.newer.domain.Member;
import com.newer.dto.PageDto;
import com.newer.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("member")
public class MemberController {
    @Autowired
    MemberService memberService;

    @RequestMapping("login")
    public List<Member> login(String name, String pwd, Model model){
         List<Member> members=this.memberService.LoginByName(name,pwd);
         model.addAttribute("members",members);
         return members;
    }

    @RequestMapping("selectPage")
    public IPage<Member> selectPage(PageDto pageDto){
        return this.memberService.selectMember(pageDto);
    }

    @RequestMapping("deleteMember")
    public void deleteMemberById(Integer id){
        this.memberService.deleteMemberById(id);
    }

    @RequestMapping("selectbyparam")
    public List<Member> selectByParam(String param){
        return this.memberService.selectByParam(param);
    }
}
